package controller;

import entity.MsgResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@Controller
public class LogoutController {

    @RequestMapping("/logout")
    @ResponseBody
    public MsgResult logout(HttpServletRequest request){
        MsgResult msgResult = new MsgResult();
        HttpSession session = request.getSession();
        session.removeAttribute("u");
        session.invalidate();
        msgResult.setFlag(1);
        msgResult.setMsg("退出成功");
        return msgResult;
    }
}
